/**
 * @Author：ming
 * @Date：2023/10/30 2:08 AM
 * @Filename：Hot138
 */

/**
 * @author ming
 */
public class Hot138 {
    public Node copyRandomList(Node head) {
        Node q = head;
        Node newHead = new Node(0);
        Node p = head;
        while (q!=null){
            Node node = new Node(q.val);
            node.next = null;
            node.random= q.random;
            p.next = node;
            p =p.next;

            q=q.next;
        }
        return newHead.next;
    }
}
